package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.AttendanceGroupDepts;
import com.group.project.hrms.mapper.AttendanceGroupDeptsMapper;
import com.group.project.hrms.service.IAttendanceGroupDeptsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class AttendanceGroupDeptsService implements IAttendanceGroupDeptsService {

    @Autowired
    private AttendanceGroupDeptsMapper attendanceGroupDeptsMapper;

    @Override
    public int insertAttendanceGroupDepts(AttendanceGroupDepts attendanceGroupDepts) {
        return attendanceGroupDeptsMapper.insert(attendanceGroupDepts);
    }

    @Override
    public int deleteAttendanceGroupDepts(AttendanceGroupDepts attendanceGroupDepts) {
        return attendanceGroupDeptsMapper.deleteByPrimaryKey(attendanceGroupDepts);
    }

    @Override
    public int updateAttendanceGroupDepts(AttendanceGroupDepts attendanceGroupDepts) {
        return attendanceGroupDeptsMapper.updateByPrimaryKey(attendanceGroupDepts);
    }

    @Override
    public AttendanceGroupDepts selectOneAttendanceGroupDepts(AttendanceGroupDepts attendanceGroupDepts) {
        return attendanceGroupDeptsMapper.selectByPrimaryKey(attendanceGroupDepts);
    }

    @Override
    public List<AttendanceGroupDepts> selectAttendanceGroupDeptsByGroupID(String gid) {
        Example example = new Example(AttendanceGroupDepts.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("attendanceGroupId" , gid);
        return attendanceGroupDeptsMapper.selectByExample(example);
    }

    @Override
    public AttendanceGroupDepts selectAttendanceGroupDeptsByDeptID(String did) {
        Example example = new Example(AttendanceGroupDepts.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("deptId" , did);
        return attendanceGroupDeptsMapper.selectOneByExample(example);
    }

    @Override
    public List<AttendanceGroupDepts> selectAllAttendanceGroupDepts() {
        return attendanceGroupDeptsMapper.selectAll();
    }
}
